<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>
<body>
  <div id="app">
    <common-head></common-head>
    <common-head2></common-head2>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 子组件
    const Child = {
      // 子组件中 定义props接收 父组件给子组件标签 添加的自定义属性
      props: ['title'], // properties
      template: `
        <div>
          <h3>这是子组件</h3>  
          <input v-model="title"/>
          <h4>{{title}}</h4>
        </div>
      `,
      mounted(){
        console.log(this);
      }
    }
    // 父组件1
    const CommonHead = {
      // 在父组件中子组件标签添加自定义属性携带数据
      template: `
        <div>
          <h2>这是一个公共的 头部组件</h2>  
          <hr/>
          <child :title="[1,2,3]"></child>
        </div>
      `,
      components: {
        Child
      }
    };
    Vue.component('CommonHead', CommonHead)
    const CommonHead2 = {
      template: `
        <div>
          <h2>这是一个公共的父组件2</h2>  
          <hr/>
          <child :title="msg"></child>
        </div>
      `,
      data(){
        return {
          msg: '这是父组件中动态的数据'
        }
      },
      components: {
        Child
      }
    };
    Vue.component('CommonHead2', CommonHead2)
    const vm = new Vue({
      el: '#app'
    })
    console.log(vm);
  </script>
</body>
</html>